#ifndef QHDOBJECT_H
#define QHDOBJECT_H

#include "trimps_forensic_global.h"

/** The object for hard disk*/
class HDObject : public QObject
{
	Q_OBJECT
public:

	/** 
	 Construct a hard disk object
	 @param rIdx the index of rack machine
	 @param lIdx the slot location of hard disk
	 @param ip	the ip address of rack machine
	 */
	HDObject(int rIdx, int lIdx, const QString& ip, QObject* parent = 0);

	/**
	 Register a hard disk
	 @param filename the filename of hard disk device (\\.\PhysicalDriveX in Windows and /dev/sdx in Linux)
	 @return false on failure and true otherwise
	*/
	bool registerDisk(const QString& filename);

	/**
	 Get the detail of hard disk such as serial number, capcity, type of hard disk
	 @param filename the filename of hard disk device (\\.\PhysicalDriveX in Windows and /dev/sdx in Linux)
	 @return false on failure and true otherwise
	 */
	bool determineDisk(const QString& filename);
	
	/** remove the hard disk */
	bool removeDisk();

	/** Is this hard disk object valid */
	bool isValid()const;
	
	/** Is this hard disk object being imaging */
	bool isCopying()const;
	
	/** Get the device name of hard disk */
	const QString& getDeviceName()const {return devname;}

	/** Get the vendor of hard disk */
	const QString& getVendor()const {return vendorID;}
	
	/** Get the model of hard disk */
	const QString& getModel()const {return productID;}
	
	/** Get the serial number of hard disk */
	const QString& getSerial()const {return sn;}
	
	/** Get the total size of hard disk */
	const quint64  getCapcity()const {return total_bytes;}
	
	/** Get the sector size of hard disk */
	const quint32  getBytesPerSector()const {return bytes_per_sector;}

	/** Set the state of hard disk */
	void setState(HDState state);

	/** Get the state of hard disk */
	HDState getState() const {return state;}

signals:
	/** This signal is emitted when the state of hd object changed */
	void stateChanged(int state);

private:
	HDState state;

	QString devname;
	QString vendorID;
	QString productID;
	QString sn;

	/*for physical location*/
	int locationIndex;
	int rackIndex;
	QString ip;

	/*for db*/
	int rId;
	int hdId;
	int hdlocId;

	unsigned int elapsed_time;
	unsigned int bytes_per_sector;
	quint64 total_bytes;
	quint64 processed_bytes;
	double mean_speed;

	friend class HDDuplicator;
	friend class ImagerTask;
	friend class RWThread;
	friend class QReadThread;
	friend class QWriteThread;
	friend class QVerifyThread;
};


#endif
